home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / renegade.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  26KB  |  819 lines

  1. /***************************************************************************
  2.  
  3. Renegade
  4. (c)1986 Taito
  5.  
  6. Nekketsu Kouha Kunio Kun
  7. (c)1986 Technos Japan
  8.  
  9. Nekketsu Kouha Kunio Kun (bootleg)
  10.  
  11. driver by Phil Stroffolino, Carlos A. Lozano, Rob Rosenbrock
  12.  
  13. to enter test mode, hold down P1+P2 and press reset
  14.  
  15. NMI is used to refresh the sprites
  16. IRQ is used to handle coin inputs
  17.  
  18. Known issues:
  19. - flipscreen isn't implemented for sprites
  20. - coin counter isn't working properly (interrupt related?)
  21.  
  22. Memory Map (Preliminary):
  23.  
  24. Working RAM
  25.   $24            used to mirror bankswitch state
  26.   $25            coin trigger state
  27.   $26            #credits (decimal)
  28.   $27 -  $28    partial credits
  29.   $2C -  $2D    sprite refresh trigger (used by NMI)
  30.   $31            live/demo (if live, player controls are read from input ports)
  31.   $32            indicates 2 player (alternating) game, or 1 player game
  32.   $33            active player
  33.   $37            stage number
  34.   $38            stage state (for stages with more than one part)
  35.   $40            game status flags; 0x80 indicates time over, 0x40 indicates player dead
  36.  $220            player health
  37.  $222 -  $223    stage timer
  38.  $48a -  $48b    horizontal scroll buffer
  39.  $511 -  $690    sprite RAM buffer
  40.  $693            num pending sound commands
  41.  $694 -  $698    sound command queue
  42.  
  43. $1002            #lives
  44. $1014 - $1015    stage timer - separated digits
  45. $1017 - $1019    stage timer: (ticks,seconds,minutes)
  46. $101a            timer for palette animation
  47. $1020 - $1048    high score table
  48. $10e5 - $10ff    68705 data buffer
  49.  
  50. Video RAM
  51. $1800 - $1bff    text layer, characters
  52. $1c00 - $1fff    text layer, character attributes
  53. $2000 - $217f    MIX RAM (96 sprites)
  54. $2800 - $2bff    BACK LOW MAP RAM (background tiles)
  55. $2C00 - $2fff    BACK HIGH MAP RAM (background attributes)
  56. $3000 - $30ff    COLOR RG RAM
  57. $3100 - $31ff    COLOR B RAM
  58.  
  59. Registers
  60. $3800w    scroll(0ff)
  61. $3801w    scroll(300)
  62. $3802w    sound command
  63. $3803w    screen flip (0=flip; 1=noflip)
  64.  
  65. $3804w    send data to 68705
  66. $3804r    receive data from 68705
  67.  
  68. $3805w    bankswitch
  69. $3806w    watchdog?
  70. $3807w    coin counter
  71.  
  72. $3800r    'player1'
  73.         xx        start buttons
  74.           xx        fire buttons
  75.             xxxx    joystick state
  76.  
  77. $3801r    'player2'
  78.         xx        coin inputs
  79.           xx        fire buttons
  80.             xxxx    joystick state
  81.  
  82. $3802r    'DIP2'
  83.         x        unused?
  84.          x        vblank
  85.           x        0: 68705 is ready to send information
  86.            x        1: 68705 is ready to receive information
  87.             xx        3rd fire buttons for player 2,1
  88.               xx    difficulty
  89.  
  90. $3803r 'DIP1'
  91.         x        screen flip
  92.          x        cabinet type
  93.           x        bonus (extra life for high score)
  94.            x        starting lives: 1 or 2
  95.             xxxx    coins per play
  96.  
  97. ROM
  98. $4000 - $7fff    bankswitched ROM
  99. $8000 - $ffff    ROM
  100.  
  101. ***************************************************************************/
  102.  
  103. #include "driver.h"
  104. #include "vidhrdw/generic.h"
  105. #include "cpu/m6502/m6502.h"
  106. #include "cpu/m6809/m6809.h"
  107.  
  108. extern void renegade_vh_screenrefresh(struct osd_bitmap *bitmap, int fullrefresh);
  109. extern int renegade_vh_start( void );
  110. WRITE_HANDLER( renegade_scroll0_w );
  111. WRITE_HANDLER( renegade_scroll1_w );
  112. WRITE_HANDLER( renegade_videoram_w );
  113. WRITE_HANDLER( renegade_textram_w );
  114. WRITE_HANDLER( renegade_flipscreen_w );
  115.  
  116. extern unsigned char *renegade_textram;
  117.  
  118. /********************************************************************************************/
  119.  
  120. static WRITE_HANDLER( adpcm_play_w ){
  121.     data -= 0x2c;
  122.     if( data >= 0 ) ADPCM_play( 0, 0x2000*data, 0x2000*2 );
  123. }
  124.  
  125. static WRITE_HANDLER( sound_w ){
  126.     soundlatch_w(offset,data);
  127.     cpu_cause_interrupt(1,M6809_INT_IRQ);
  128. }
  129.  
  130. /********************************************************************************************/
  131. /*    MCU Simulation
  132. **
  133. **    Renegade and Nekketsu Kouha Kunio Kun MCU behaviors are identical,
  134. **    except for the initial MCU status byte, and command encryption table.
  135. */
  136.  
  137. static int mcu_type;
  138. static const unsigned char *mcu_encrypt_table;
  139. static int mcu_encrypt_table_len;
  140.  
  141. static const UINT8 renegade_xor_table[0x37] = {
  142.     0x8A,0x48,0x98,0x48,0xA9,0x00,0x85,0x14,0x85,0x15,0xA5,0x11,0x05,0x10,0xF0,0x21,
  143.     0x46,0x11,0x66,0x10,0x90,0x0F,0x18,0xA5,0x14,0x65,0x12,0x85,0x14,0xA5,0x15,0x65,
  144.     0x13,0x85,0x15,0xB0,0x06,0x06,0x12,0x26,0x13,0x90,0xDF,0x68,0xA8,0x68,0xAA,0x38,
  145.     0x60,0x68,0xA8,0x68,0xAA,0x18,0x60
  146. };
  147.  
  148. static const UINT8 kuniokun_xor_table[0x2a] = {
  149.     0x48,0x8a,0x48,0xa5,0x01,0x48,0xa9,0x00,0x85,0x01,0xa2,0x10,0x26,0x10,0x26,0x11,
  150.     0x26,0x01,0xa5,0x01,0xc5,0x00,0x90,0x04,0xe5,0x00,0x85,0x01,0x26,0x10,0x26,0x11,
  151.     0xca,0xd0,0xed,0x68,0x85,0x01,0x68,0xaa,0x68,0x60
  152. };
  153.  
  154. void init_kuniokun( void )
  155. {
  156.     mcu_type = 0x85;
  157.     mcu_encrypt_table = kuniokun_xor_table;
  158.     mcu_encrypt_table_len = 0x2a;
  159. }
  160. void init_renegade( void )
  161. {
  162.     mcu_type = 0xda;
  163.     mcu_encrypt_table = renegade_xor_table;
  164.     mcu_encrypt_table_len = 0x37;
  165. }
  166.  
  167. #define MCU_BUFFER_MAX 6
  168. static unsigned char mcu_buffer[MCU_BUFFER_MAX];
  169. static size_t mcu_input_size;
  170. static int mcu_output_byte;
  171. static int mcu_key;
  172.  
  173. static READ_HANDLER( mcu_reset_r ){
  174.     mcu_key = -1;
  175.     mcu_input_size = 0;
  176.     mcu_output_byte = 0;
  177.     return 0;
  178. }
  179.  
  180. static WRITE_HANDLER( mcu_w ){
  181.     mcu_output_byte = 0;
  182.  
  183.     if( mcu_key<0 ){
  184.         mcu_key = 0;
  185.         mcu_input_size = 1;
  186.         mcu_buffer[0] = data;
  187.     }
  188.     else {
  189.         data ^= mcu_encrypt_table[mcu_key];
  190.         if( ++mcu_key==mcu_encrypt_table_len) mcu_key = 0;
  191.         if( mcu_input_size<MCU_BUFFER_MAX ) mcu_buffer[mcu_input_size++] = data;
  192.     }
  193. }
  194.  
  195. static void mcu_process_command( void ){
  196.     mcu_input_size = 0;
  197.     mcu_output_byte = 0;
  198.  
  199.     switch( mcu_buffer[0] ){
  200.         case 0x10:
  201.         mcu_buffer[0] = mcu_type;
  202.         break;
  203.  
  204.         case 0x26: /* sound code -> sound command */
  205.         {
  206.             int sound_code = mcu_buffer[1];
  207.             static const unsigned char sound_command_table[256] = {
  208.                 0xa0,0xa1,0xa2,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,
  209.                 0x8d,0x8e,0x8f,0x97,0x96,0x9b,0x9a,0x95,0x9e,0x98,0x90,0x93,0x9d,0x9c,0xa3,0x91,
  210.                 0x9f,0x99,0xa6,0xae,0x94,0xa5,0xa4,0xa7,0x92,0xab,0xac,0xb0,0xb1,0xb2,0xb3,0xb4,
  211.                 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  212.                 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  213.                 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x20,
  214.                 0x50,0x50,0x90,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  215.                 0x00,0x00,0x00,0x80,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  216.                 0x00,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  217.                 0x20,0x00,0x00,0x10,0x10,0x00,0x00,0x90,0x30,0x30,0x30,0xb0,0xb0,0xb0,0xb0,0xf0,
  218.                 0xf0,0xf0,0xf0,0xd0,0xf0,0x00,0x00,0x00,0x00,0x10,0x10,0x50,0x30,0xb0,0xb0,0xf0,
  219.                 0xf0,0xf0,0xf0,0xf0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
  220.                 0x10,0x10,0x30,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  221.                 0x00,0x00,0x00,0x00,0x00,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
  222.                 0x0f,0x0f,0x0f,0x0f,0x0f,0x8f,0x8f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,0x0f,
  223.                 0x0f,0x0f,0x0f,0x0f,0x0f,0xff,0xff,0xff,0xef,0xef,0xcf,0x8f,0x8f,0x0f,0x0f,0x0f
  224.             };
  225.             mcu_buffer[0] = 1;
  226.             mcu_buffer[1] = sound_command_table[sound_code];
  227.         }
  228.         break;
  229.  
  230.         case 0x33: /* joy bits -> joy dir */
  231.         {
  232.             int joy_bits = mcu_buffer[2];
  233.             static const unsigned char joy_table[0x10] = {
  234.                 0,3,7,0,1,2,8,0,5,4,6,0,0,0,0,0
  235.             };
  236.             mcu_buffer[0] = 1;
  237.             mcu_buffer[1] = joy_table[joy_bits&0xf];
  238.         }
  239.         break;
  240.  
  241.         case 0x44: /* 0x44,0xff,DSW2,stage# -> difficulty */
  242.         {
  243.             int difficulty = mcu_buffer[2]&0x3;
  244.             int stage = mcu_buffer[3];
  245.             const unsigned char difficulty_table[4] = { 5,3,1,2 };
  246.             int result = difficulty_table[difficulty];
  247.             if( stage==0 ) result--;
  248.             result += stage/4;
  249.             mcu_buffer[0] = 1;
  250.             mcu_buffer[1] = result;
  251.         }
  252.  
  253.         case 0x55: /* 0x55,0x00,0x00,0x00,DSW2 -> timer */
  254.         {
  255.             int difficulty = mcu_buffer[4]&0x3;
  256.             const UINT16 table[4] = {
  257.                 0x4001,0x5001,0x1502,0x0002
  258.             };
  259.  
  260.             mcu_buffer[0] = 3;
  261.             mcu_buffer[2] = table[difficulty]>>8;
  262.             mcu_buffer[3] = table[difficulty]&0xff;
  263.         }
  264.         break;
  265.  
  266.         case 0x41: { /* 0x41,0x00,0x00,stage# -> ? */
  267. //            int stage = mcu_buffer[3];
  268.             mcu_buffer[0] = 2;
  269.             mcu_buffer[1] = 0x20;
  270.             mcu_buffer[2] = 0x78;
  271.         }
  272.         break;
  273.  
  274.         case 0x40: /* 0x40,0x00,difficulty,enemy_type -> enemy health */
  275.         {
  276.             int difficulty = mcu_buffer[2];
  277.             int enemy_type = mcu_buffer[3];
  278.             int health;
  279.  
  280.             if( enemy_type<=4 || (enemy_type&1)==0 ) health = 0x18 + difficulty*8;
  281.             else health = 0x06 + difficulty*2;
  282.             logerror("e_type:0x%02x diff:0x%02x -> 0x%02x\n", enemy_type, difficulty, health );
  283.             mcu_buffer[0] = 1;
  284.             mcu_buffer[1] = health;
  285.         }
  286.         break;
  287.  
  288.         case 0x42: /* 0x42,0x00,stage#,character# -> enemy_type */
  289.         {
  290.             int stage = mcu_buffer[2]&0x3;
  291.             int indx = mcu_buffer[3];
  292.             int enemy_type=0;
  293.  
  294.             if( indx==0 ){
  295.                 enemy_type = 1+stage; /* boss */
  296.             }
  297.             else {
  298.                 switch( stage ){
  299.                     case 0x00:
  300.                     if( indx<=2 ) enemy_type = 0x06; else enemy_type = 0x05;
  301.                     break;
  302.  
  303.                     case 0x01:
  304.                     if( indx<=2 ) enemy_type = 0x0a; else enemy_type = 0x09;
  305.                     break;
  306.  
  307.                     case 0x02:
  308.                     if( indx<=3 ) enemy_type = 0x0e; else enemy_type = 0xd;
  309.                     break;
  310.  
  311.                     case 0x03:
  312.                     enemy_type = 0x12;
  313.                     break;
  314.                 }
  315.             }
  316.             mcu_buffer[0] = 1;
  317.             mcu_buffer[1] = enemy_type;
  318.         }
  319.         break;
  320.  
  321.         default:
  322.         logerror("unknown MCU command: %02x\n", mcu_buffer[0] );
  323.         break;
  324.     }
  325. }
  326.  
  327. static READ_HANDLER( mcu_r ){
  328.     int result = 1;
  329.  
  330.     if( mcu_input_size ) mcu_process_command();
  331.  
  332.     if( mcu_output_byte<MCU_BUFFER_MAX )
  333.         result = mcu_buffer[mcu_output_byte++];
  334.  
  335.     return result;
  336. }
  337.  
  338. /********************************************************************************************/
  339.  
  340. static int bank;
  341.  
  342. static WRITE_HANDLER( bankswitch_w ){
  343.     if( (data&1)!=bank ){
  344.         unsigned char *RAM = memory_region(REGION_CPU1);
  345.         bank = data&1;
  346.         cpu_setbank(1,&RAM[ bank?0x10000:0x4000 ]);
  347.     }
  348. }
  349.  
  350. static int renegade_interrupt(void){
  351. /*
  352.     static int coin;
  353.     int port = readinputport(1) & 0xc0;
  354.     if (port != 0xc0 ){
  355.         if (coin == 0){
  356.             coin = 1;
  357.             return interrupt();
  358.         }
  359.     }
  360.     else coin = 0;
  361. */
  362.  
  363.     static int count;
  364.     count = !count;
  365.     if( count )
  366.     return nmi_interrupt();
  367.     return interrupt();
  368. }
  369.  
  370. /********************************************************************************************/
  371.  
  372. static struct MemoryReadAddress main_readmem[] = {
  373.     { 0x0000, 0x37ff, MRA_RAM },
  374.     { 0x3800, 0x3800, input_port_0_r },    /* Player#1 controls; P1,P2 start */
  375.     { 0x3801, 0x3801, input_port_1_r },    /* Player#2 controls; coin triggers */
  376.     { 0x3802, 0x3802, input_port_2_r },    /* DIP2 ; various IO ports */
  377.     { 0x3803, 0x3803, input_port_3_r },    /* DIP1 */
  378.     { 0x3804, 0x3804, mcu_r },
  379.     { 0x3805, 0x3805, mcu_reset_r },
  380.     { 0x4000, 0x7fff, MRA_BANK1 },
  381.     { 0x8000, 0xffff, MRA_ROM },
  382.     { -1 }
  383. };
  384.  
  385. static struct MemoryWriteAddress main_writemem[] = {
  386.     { 0x0000, 0x17ff, MWA_RAM },
  387.     { 0x1800, 0x1fff, renegade_textram_w, &renegade_textram },
  388.     { 0x2000, 0x27ff, MWA_RAM, &spriteram },
  389.     { 0x2800, 0x2fff, renegade_videoram_w, &videoram },
  390.     { 0x3000, 0x30ff, paletteram_xxxxBBBBGGGGRRRR_split1_w, &paletteram },
  391.     { 0x3100, 0x31ff, paletteram_xxxxBBBBGGGGRRRR_split2_w, &paletteram_2 },
  392.     { 0x3800, 0x3800, renegade_scroll0_w },
  393.     { 0x3801, 0x3801, renegade_scroll1_w },
  394.     { 0x3802, 0x3802, sound_w },
  395.     { 0x3803, 0x3803, renegade_flipscreen_w },
  396.     { 0x3804, 0x3804, mcu_w },
  397.     { 0x3805, 0x3805, bankswitch_w },
  398.     { 0x3806, 0x3806, MWA_NOP }, /* watchdog? */
  399.     { 0x3807, 0x3807, coin_counter_w },
  400.     { 0x4000, 0xffff, MWA_ROM },
  401.     { -1 }
  402. };
  403.  
  404. static struct MemoryReadAddress sound_readmem[] = {
  405.     { 0x0000, 0x0fff, MRA_RAM },
  406.     { 0x1000, 0x1000, soundlatch_r },
  407.     { 0x2801, 0x2801, YM3526_status_port_0_r },
  408.     { 0x8000, 0xffff, MRA_ROM },
  409.     { -1 }
  410. };
  411.  
  412. static struct MemoryWriteAddress sound_writemem[] = {
  413.     { 0x0000, 0x0fff, MWA_RAM },
  414.     { 0x1800, 0x1800, MWA_NOP }, // this gets written the same values as 0x2000
  415.     { 0x2000, 0x2000, adpcm_play_w },
  416.     { 0x2800, 0x2800, YM3526_control_port_0_w },
  417.     { 0x2801, 0x2801, YM3526_write_port_0_w },
  418.     { 0x3000, 0x3000, MWA_NOP }, /* adpcm related? stereo pan? */
  419.     { 0x8000, 0xffff, MWA_ROM },
  420.     { -1 }
  421. };
  422.  
  423.  
  424.  
  425. INPUT_PORTS_START( renegade )
  426.     PORT_START    /* IN0 */
  427.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  428.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  429.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY )
  430.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  431.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )    /* attack left */
  432.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )    /* jump */
  433.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
  434.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  435.  
  436.     PORT_START    /* IN1 */
  437.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  438.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2)
  439.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2)
  440.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2)
  441.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2)
  442.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2)
  443.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
  444.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
  445.  
  446.     PORT_START /* DIP2 */
  447.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
  448.     PORT_DIPSETTING(    0x02, "Easy" )
  449.     PORT_DIPSETTING(    0x03, "Normal" )
  450.     PORT_DIPSETTING(    0x01, "Hard" )
  451.     PORT_DIPSETTING(    0x00, "Very Hard" )
  452.  
  453.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 )    /* attack right */
  454.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  455.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )        /* 68705 status */
  456.     PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED )    /* 68705 status */
  457.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_VBLANK )
  458.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  459.  
  460.     PORT_START /* DIP1 */
  461.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
  462.     PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
  463.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  464.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  465.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_3C ) )
  466.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
  467.     PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
  468.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
  469.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
  470.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
  471.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Lives ) )
  472.     PORT_DIPSETTING (   0x10, "1" )
  473.     PORT_DIPSETTING (   0x00, "2" )
  474.     PORT_DIPNAME( 0x20, 0x20, "Bonus" )
  475.     PORT_DIPSETTING (   0x20, "30k" )
  476.     PORT_DIPSETTING (   0x00, "None" )
  477.     PORT_DIPNAME(0x40, 0x00, DEF_STR( Cabinet ) )
  478.     PORT_DIPSETTING (  0x00, DEF_STR( Upright ) )
  479.     PORT_DIPSETTING (  0x40, DEF_STR( Cocktail ) )
  480.     PORT_DIPNAME(0x80, 0x80, DEF_STR( Flip_Screen ) )
  481.     PORT_DIPSETTING (  0x80, DEF_STR( Off ) )
  482.     PORT_DIPSETTING (  0x00, DEF_STR( On ) )
  483. INPUT_PORTS_END
  484.  
  485.  
  486.  
  487. static struct GfxLayout charlayout =
  488. {
  489.     8,8, /* 8x8 characters */
  490.     1024, /* 1024 characters */
  491.     3, /* bits per pixel */
  492.     { 2, 4, 6 },    /* plane offsets; bit 0 is always clear */
  493.     { 1, 0, 65, 64, 129, 128, 193, 192 }, /* x offsets */
  494.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, /* y offsets */
  495.     32*8 /* offset to next character */
  496. };
  497.  
  498. static struct GfxLayout tileslayout1 =
  499. {
  500.     16,16, /* tile size */
  501.     256, /* number of tiles */
  502.     3, /* bits per pixel */
  503.  
  504.     /* plane offsets */
  505.     { 4, 0x8000*8+0, 0x8000*8+4 },
  506.  
  507.     /* x offsets */
  508.     { 3, 2, 1, 0, 16*8+3, 16*8+2, 16*8+1, 16*8+0,
  509.         32*8+3,32*8+2 ,32*8+1 ,32*8+0 ,48*8+3 ,48*8+2 ,48*8+1 ,48*8+0 },
  510.  
  511.     /* y offsets */
  512.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  513.         8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  514.  
  515.     64*8 /* offset to next tile */
  516. };
  517.  
  518. static struct GfxLayout tileslayout2 =
  519. {
  520.     16,16, /* tile size */
  521.     256, /* number of tiles */
  522.     3, /* bits per pixel */
  523.  
  524.     /* plane offsets */
  525.     { 0, 0xC000*8+0, 0xC000*8+4 },
  526.  
  527.     /* x offsets */
  528.     { 3, 2, 1, 0, 16*8+3, 16*8+2, 16*8+1, 16*8+0,
  529.         32*8+3,32*8+2 ,32*8+1 ,32*8+0 ,48*8+3 ,48*8+2 ,48*8+1 ,48*8+0 },
  530.  
  531.     /* y offsets */
  532.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  533.         8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  534.  
  535.     64*8 /* offset to next tile */
  536. };
  537.  
  538. static struct GfxLayout tileslayout3 =
  539. {
  540.     16,16, /* tile size */
  541.     256, /* number of tiles */
  542.     3, /* bits per pixel */
  543.  
  544.     /* plane offsets */
  545.     { 0x4000*8+4, 0x10000*8+0, 0x10000*8+4 },
  546.  
  547.     /* x offsets */
  548.     { 3, 2, 1, 0, 16*8+3, 16*8+2, 16*8+1, 16*8+0,
  549.         32*8+3,32*8+2 ,32*8+1 ,32*8+0 ,48*8+3 ,48*8+2 ,48*8+1 ,48*8+0 },
  550.  
  551.     /* y offsets */
  552.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  553.         8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  554.  
  555.     64*8 /* offset to next tile */
  556. };
  557.  
  558. static struct GfxLayout tileslayout4 =
  559. {
  560.     16,16, /* tile size */
  561.     256, /* number of tiles */
  562.     3, /* bits per pixel */
  563.  
  564.     /* plane offsets */
  565.     { 0x4000*8+0, 0x14000*8+0, 0x14000*8+4 },
  566.  
  567.     /* x offsets */
  568.     { 3, 2, 1, 0, 16*8+3, 16*8+2, 16*8+1, 16*8+0,
  569.         32*8+3,32*8+2 ,32*8+1 ,32*8+0 ,48*8+3 ,48*8+2 ,48*8+1 ,48*8+0 },
  570.  
  571.     /* y offsets */
  572.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  573.         8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  574.  
  575.     64*8 /* offset to next tile */
  576. };
  577.  
  578. static struct GfxDecodeInfo gfxdecodeinfo[] =
  579. {
  580.     /* 8x8 text, 8 colors */
  581.     { REGION_GFX1, 0x00000, &charlayout,     0, 4 },    /* colors   0- 32 */
  582.  
  583.     /* 16x16 background tiles, 8 colors */
  584.     { REGION_GFX2, 0x00000, &tileslayout1, 192, 8 },    /* colors 192-255 */
  585.     { REGION_GFX2, 0x00000, &tileslayout2, 192, 8 },
  586.     { REGION_GFX2, 0x00000, &tileslayout3, 192, 8 },
  587.     { REGION_GFX2, 0x00000, &tileslayout4, 192, 8 },
  588.  
  589.     { REGION_GFX2, 0x18000, &tileslayout1, 192, 8 },
  590.     { REGION_GFX2, 0x18000, &tileslayout2, 192, 8 },
  591.     { REGION_GFX2, 0x18000, &tileslayout3, 192, 8 },
  592.     { REGION_GFX2, 0x18000, &tileslayout4, 192, 8 },
  593.  
  594.     /* 16x16 sprites, 8 colors */
  595.     { REGION_GFX3, 0x00000, &tileslayout1, 128, 4 },    /* colors 128-159 */
  596.     { REGION_GFX3, 0x00000, &tileslayout2, 128, 4 },
  597.     { REGION_GFX3, 0x00000, &tileslayout3, 128, 4 },
  598.     { REGION_GFX3, 0x00000, &tileslayout4, 128, 4 },
  599.  
  600.     { REGION_GFX3, 0x18000, &tileslayout1, 128, 4 },
  601.     { REGION_GFX3, 0x18000, &tileslayout2, 128, 4 },
  602.     { REGION_GFX3, 0x18000, &tileslayout3, 128, 4 },
  603.     { REGION_GFX3, 0x18000, &tileslayout4, 128, 4 },
  604.  
  605.     { REGION_GFX3, 0x30000, &tileslayout1, 128, 4 },
  606.     { REGION_GFX3, 0x30000, &tileslayout2, 128, 4 },
  607.     { REGION_GFX3, 0x30000, &tileslayout3, 128, 4 },
  608.     { REGION_GFX3, 0x30000, &tileslayout4, 128, 4 },
  609.  
  610.     { REGION_GFX3, 0x48000, &tileslayout1, 128, 4 },
  611.     { REGION_GFX3, 0x48000, &tileslayout2, 128, 4 },
  612.     { REGION_GFX3, 0x48000, &tileslayout3, 128, 4 },
  613.     { REGION_GFX3, 0x48000, &tileslayout4, 128, 4 },
  614.     { -1 }
  615. };
  616.  
  617.  
  618.  
  619. /* handler called by the 3526 emulator when the internal timers cause an IRQ */
  620. static void irqhandler(int linestate)
  621. {
  622.     cpu_set_irq_line(1,M6809_FIRQ_LINE,linestate);
  623.     //cpu_cause_interrupt(1,M6809_INT_FIRQ);
  624. }
  625.  
  626. static struct YM3526interface ym3526_interface = {
  627.     1,            /* 1 chip (no more supported) */
  628.     3000000,    /* 3 MHz ? (hand tuned) */
  629.     { 50 },        /* volume */
  630.     { irqhandler },
  631. };
  632.  
  633. static struct ADPCMinterface adpcm_interface =
  634. {
  635.     1,            /* 1 channel */
  636.     8000,        /* 8000Hz playback */
  637.     REGION_SOUND1,    /* memory region */
  638.     0,            /* init function */
  639.     { 100 }        /* volume */
  640. };
  641.  
  642.  
  643.  
  644. static struct MachineDriver machine_driver_renegade =
  645. {
  646.     {
  647.         {
  648.              CPU_M6502,
  649.             1500000,    /* 1.5 MHz? */
  650.             main_readmem,main_writemem,0,0,
  651.             renegade_interrupt,2
  652.         },
  653.         {
  654.              CPU_M6809 | CPU_AUDIO_CPU,
  655.             1500000,    /* ? */
  656.             sound_readmem,sound_writemem,0,0,
  657.             ignore_interrupt,0,    /* FIRQs are caused by the YM3526 */
  658.                                 /* IRQs are caused by the main CPU */
  659.         }
  660.     },
  661.     60,
  662.  
  663.     DEFAULT_REAL_60HZ_VBLANK_DURATION*2,
  664.  
  665.     1, /* cpu slices */
  666.     0, /* init machine */
  667.  
  668.     32*8, 32*8, { 1*8, 31*8-1, 0, 30*8-1 },
  669.     gfxdecodeinfo,
  670.     256,256,
  671.     0,
  672.  
  673.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  674.     0,
  675.     renegade_vh_start,0,
  676.     renegade_vh_screenrefresh,
  677.  
  678.     /* sound hardware */
  679.     0,0,0,0,
  680.     {
  681.         {
  682.             SOUND_YM3526,
  683.             &ym3526_interface
  684.         },
  685.         {
  686.             SOUND_ADPCM,
  687.             &adpcm_interface
  688.         }
  689.     }
  690. };
  691.  
  692.  
  693.  
  694. ROM_START( renegade )
  695.     ROM_REGION( 0x14000, REGION_CPU1 )    /* 64k for code + bank switched ROM */
  696.     ROM_LOAD( "nb-5.bin",     0x08000, 0x8000, 0xba683ddf )
  697.     ROM_LOAD( "na-5.bin",     0x04000, 0x4000, 0xde7e7df4 )
  698.     ROM_CONTINUE(             0x10000, 0x4000 )
  699.  
  700.     ROM_REGION( 0x10000, REGION_CPU2 ) /* audio CPU (M6809) */
  701.     ROM_LOAD( "n0-5.bin",     0x08000, 0x08000, 0x3587de3b )
  702.  
  703.     ROM_REGION( 0x08000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  704.     ROM_LOAD( "nc-5.bin",     0x00000, 0x8000, 0x9adfaa5d )    /* characters */
  705.  
  706.     ROM_REGION( 0x30000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  707.     ROM_LOAD( "n1-5.bin",     0x00000, 0x8000, 0x4a9f47f3 )    /* tiles */
  708.     ROM_LOAD( "n6-5.bin",     0x08000, 0x8000, 0xd62a0aa8 )
  709.     ROM_LOAD( "n7-5.bin",     0x10000, 0x8000, 0x7ca5a532 )
  710.     ROM_LOAD( "n2-5.bin",     0x18000, 0x8000, 0x8d2e7982 )
  711.     ROM_LOAD( "n8-5.bin",     0x20000, 0x8000, 0x0dba31d3 )
  712.     ROM_LOAD( "n9-5.bin",     0x28000, 0x8000, 0x5b621b6a )
  713.  
  714.     ROM_REGION( 0x60000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  715.     ROM_LOAD( "nh-5.bin",     0x00000, 0x8000, 0xdcd7857c )    /* sprites */
  716.     ROM_LOAD( "nd-5.bin",     0x08000, 0x8000, 0x2de1717c )
  717.     ROM_LOAD( "nj-5.bin",     0x10000, 0x8000, 0x0f96a18e )
  718.     ROM_LOAD( "nn-5.bin",     0x18000, 0x8000, 0x1bf15787 )
  719.     ROM_LOAD( "ne-5.bin",     0x20000, 0x8000, 0x924c7388 )
  720.     ROM_LOAD( "nk-5.bin",     0x28000, 0x8000, 0x69499a94 )
  721.     ROM_LOAD( "ni-5.bin",     0x30000, 0x8000, 0x6f597ed2 )
  722.     ROM_LOAD( "nf-5.bin",     0x38000, 0x8000, 0x0efc8d45 )
  723.     ROM_LOAD( "nl-5.bin",     0x40000, 0x8000, 0x14778336 )
  724.     ROM_LOAD( "no-5.bin",     0x48000, 0x8000, 0x147dd23b )
  725.     ROM_LOAD( "ng-5.bin",     0x50000, 0x8000, 0xa8ee3720 )
  726.     ROM_LOAD( "nm-5.bin",     0x58000, 0x8000, 0xc100258e )
  727.  
  728.     ROM_REGION( 0x20000, REGION_SOUND1 ) /* adpcm */
  729.     ROM_LOAD( "n5-5.bin",     0x00000, 0x8000, 0x7ee43a3c )
  730.     ROM_LOAD( "n4-5.bin",     0x10000, 0x8000, 0x6557564c )
  731.     ROM_LOAD( "n3-5.bin",     0x18000, 0x8000, 0x78fd6190 )
  732. ROM_END
  733.  
  734. ROM_START( kuniokun )
  735.     ROM_REGION( 0x14000, REGION_CPU1 )    /* 64k for code + bank switched ROM */
  736.     ROM_LOAD( "nb-01.bin",      0x08000, 0x8000, 0x93fcfdf5 ) // original
  737.     ROM_LOAD( "ta18-11.bin",  0x04000, 0x4000, 0xf240f5cd )
  738.     ROM_CONTINUE(             0x10000, 0x4000 )
  739.  
  740.     ROM_REGION( 0x10000, REGION_CPU2 ) /* audio CPU (M6809) */
  741.     ROM_LOAD( "n0-5.bin",     0x08000, 0x08000, 0x3587de3b )
  742.  
  743.     ROM_REGION( 0x08000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  744.     ROM_LOAD( "ta18-25.bin",  0x00000, 0x8000, 0x9bd2bea3 )    /* characters */
  745.  
  746.     ROM_REGION( 0x30000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  747.     ROM_LOAD( "ta18-01.bin",  0x00000, 0x8000, 0xdaf15024 )    /* tiles */
  748.     ROM_LOAD( "ta18-06.bin",  0x08000, 0x8000, 0x1f59a248 )
  749.     ROM_LOAD( "n7-5.bin",     0x10000, 0x8000, 0x7ca5a532 )
  750.     ROM_LOAD( "ta18-02.bin",  0x18000, 0x8000, 0x994c0021 )
  751.     ROM_LOAD( "ta18-04.bin",  0x20000, 0x8000, 0x55b9e8aa )
  752.     ROM_LOAD( "ta18-03.bin",  0x28000, 0x8000, 0x0475c99a )
  753.  
  754.     ROM_REGION( 0x60000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  755.     ROM_LOAD( "ta18-20.bin",  0x00000, 0x8000, 0xc7d54139 )    /* sprites */
  756.     ROM_LOAD( "ta18-24.bin",  0x08000, 0x8000, 0x84677d45 )
  757.     ROM_LOAD( "ta18-18.bin",  0x10000, 0x8000, 0x1c770853 )
  758.     ROM_LOAD( "ta18-14.bin",  0x18000, 0x8000, 0xaf656017 )
  759.     ROM_LOAD( "ta18-23.bin",  0x20000, 0x8000, 0x3fd19cf7 )
  760.     ROM_LOAD( "ta18-17.bin",  0x28000, 0x8000, 0x74c64c6e )
  761.     ROM_LOAD( "ta18-19.bin",  0x30000, 0x8000, 0xc8795fd7 )
  762.     ROM_LOAD( "ta18-22.bin",  0x38000, 0x8000, 0xdf3a2ff5 )
  763.     ROM_LOAD( "ta18-16.bin",  0x40000, 0x8000, 0x7244bad0 )
  764.     ROM_LOAD( "ta18-13.bin",  0x48000, 0x8000, 0xb6b14d46 )
  765.     ROM_LOAD( "ta18-21.bin",  0x50000, 0x8000, 0xc95e009b )
  766.     ROM_LOAD( "ta18-15.bin",  0x58000, 0x8000, 0xa5d61d01 )
  767.  
  768.     ROM_REGION( 0x20000, REGION_SOUND1 ) /* adpcm */
  769.     ROM_LOAD( "ta18-07.bin",  0x00000, 0x8000, 0x02e3f3ed )
  770.     ROM_LOAD( "ta18-08.bin",  0x10000, 0x8000, 0xc9312613 )
  771.     ROM_LOAD( "ta18-09.bin",  0x18000, 0x8000, 0x07ed4705 )
  772. ROM_END
  773.  
  774. ROM_START( kuniokub )
  775.     ROM_REGION( 0x14000, REGION_CPU1 )    /* 64k for code + bank switched ROM */
  776.     ROM_LOAD( "ta18-10.bin",  0x08000, 0x8000, 0xa90cf44a ) // bootleg
  777.     ROM_LOAD( "ta18-11.bin",  0x04000, 0x4000, 0xf240f5cd )
  778.     ROM_CONTINUE(             0x10000, 0x4000 )
  779.  
  780.     ROM_REGION( 0x10000, REGION_CPU2 ) /* audio CPU (M6809) */
  781.     ROM_LOAD( "n0-5.bin",     0x08000, 0x08000, 0x3587de3b )
  782.  
  783.     ROM_REGION( 0x08000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  784.     ROM_LOAD( "ta18-25.bin",  0x00000, 0x8000, 0x9bd2bea3 )    /* characters */
  785.  
  786.     ROM_REGION( 0x30000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  787.     ROM_LOAD( "ta18-01.bin",  0x00000, 0x8000, 0xdaf15024 )    /* tiles */
  788.     ROM_LOAD( "ta18-06.bin",  0x08000, 0x8000, 0x1f59a248 )
  789.     ROM_LOAD( "n7-5.bin",     0x10000, 0x8000, 0x7ca5a532 )
  790.     ROM_LOAD( "ta18-02.bin",  0x18000, 0x8000, 0x994c0021 )
  791.     ROM_LOAD( "ta18-04.bin",  0x20000, 0x8000, 0x55b9e8aa )
  792.     ROM_LOAD( "ta18-03.bin",  0x28000, 0x8000, 0x0475c99a )
  793.  
  794.     ROM_REGION( 0x60000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  795.     ROM_LOAD( "ta18-20.bin",  0x00000, 0x8000, 0xc7d54139 )    /* sprites */
  796.     ROM_LOAD( "ta18-24.bin",  0x08000, 0x8000, 0x84677d45 )
  797.     ROM_LOAD( "ta18-18.bin",  0x10000, 0x8000, 0x1c770853 )
  798.     ROM_LOAD( "ta18-14.bin",  0x18000, 0x8000, 0xaf656017 )
  799.     ROM_LOAD( "ta18-23.bin",  0x20000, 0x8000, 0x3fd19cf7 )
  800.     ROM_LOAD( "ta18-17.bin",  0x28000, 0x8000, 0x74c64c6e )
  801.     ROM_LOAD( "ta18-19.bin",  0x30000, 0x8000, 0xc8795fd7 )
  802.     ROM_LOAD( "ta18-22.bin",  0x38000, 0x8000, 0xdf3a2ff5 )
  803.     ROM_LOAD( "ta18-16.bin",  0x40000, 0x8000, 0x7244bad0 )
  804.     ROM_LOAD( "ta18-13.bin",  0x48000, 0x8000, 0xb6b14d46 )
  805.     ROM_LOAD( "ta18-21.bin",  0x50000, 0x8000, 0xc95e009b )
  806.     ROM_LOAD( "ta18-15.bin",  0x58000, 0x8000, 0xa5d61d01 )
  807.  
  808.     ROM_REGION( 0x20000, REGION_SOUND1 ) /* adpcm */
  809.     ROM_LOAD( "ta18-07.bin",  0x00000, 0x8000, 0x02e3f3ed )
  810.     ROM_LOAD( "ta18-08.bin",  0x10000, 0x8000, 0xc9312613 )
  811.     ROM_LOAD( "ta18-09.bin",  0x18000, 0x8000, 0x07ed4705 )
  812. ROM_END
  813.  
  814.  
  815.  
  816. GAMEX( 1986, renegade, 0,        renegade, renegade, renegade, ROT0, "Technos (Taito America license)", "Renegade (US)", GAME_NO_COCKTAIL )
  817. GAMEX( 1986, kuniokun, renegade, renegade, renegade, kuniokun, ROT0, "Technos", "Nekketsu Kouha Kunio-kun (Japan)", GAME_NO_COCKTAIL )
  818. GAMEX( 1986, kuniokub, renegade, renegade, renegade, 0,        ROT0, "bootleg", "Nekketsu Kouha Kunio-kun (Japan bootleg)", GAME_NO_COCKTAIL )
  819.